var http = require("http");
var fs = require("fs");
var path = require("path");

http.createServer((req, res)=>{ //res是可写流，继承stream.Readable
    var filePath = path.join(__dirname, "/2.txt"); //读2.txt的内容
    var readable = fs.createReadStream(filePath); 
    readable.pipe(res); 

}).listen(8081)

console.log("server is listening 8081");

//浏览器中输入 http://localhost:8081/，会显示2.txt的内容